//
//  ShopCommonModel.m
//  LazyCat
//
//  Created by zhanshu on 15/9/9.
//  Copyright (c) 2015年 zhanshu. All rights reserved.
//

#import "ShopCommonModel.h"

@implementation ShopCommonModel

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:self.shopuser forKey:@"shopuser"];
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:self.img forKey:@"img"];
    [aCoder encodeObject:self.url forKey:@"url"];
    [aCoder encodeObject:self.shopname forKey:@"shopname"];
    [aCoder encodeObject:self.opentime forKey:@"opentime"];
    [aCoder encodeObject:self.x forKey:@"x"];
    [aCoder encodeObject:self.y forKey:@"y"];
    [aCoder encodeObject:self.distance forKey:@"distance"];
    [aCoder encodeObject:self.address forKey:@"address"];
    [aCoder encodeObject:self.city forKey:@"city"];
    [aCoder encodeObject:self.cityid forKey:@"cityid"];
    [aCoder encodeObject:self.tag forKey:@"tag"];
}
- (id)initWithCoder:(NSCoder *)aDecoder {
    self.shopuser = [aDecoder decodeObjectForKey:@"shopuser"];
    self.name = [aDecoder decodeObjectForKey:@"name"];
    self.img = [aDecoder decodeObjectForKey:@"img"];
    self.url = [aDecoder decodeObjectForKey:@"url"];
    self.shopname = [aDecoder decodeObjectForKey:@"shopname"];
    self.opentime = [aDecoder decodeObjectForKey:@"opentime"];
    self.x = [aDecoder decodeObjectForKey:@"x"];
    self.y = [aDecoder decodeObjectForKey:@"y"];
    self.distance = [aDecoder decodeObjectForKey:@"distance"];
    self.address = [aDecoder decodeObjectForKey:@"address"];
    self.city = [aDecoder decodeObjectForKey:@"city"];
    self.cityid = [aDecoder decodeObjectForKey:@"cityid"];
    self.tag = [aDecoder decodeObjectForKey:@"tag"];
    return self;
}

// 写入本地磁盘
+ (void)saveShopMess:(id)model {
    NSData *myEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:model];
    [NSUserDefualManager storageValue:myEncodedObject forKey:LC_ShopMess_Model];
}
// 过去商品信息
+ (ShopCommonModel *)getShopMess {
    NSData *myEncodedObject = [NSUserDefualManager getValueByKey:LC_ShopMess_Model];
    ShopCommonModel *aModel = [NSKeyedUnarchiver unarchiveObjectWithData:myEncodedObject];
    return aModel;
}
@end
